package cn.exrick.xboot.modules.base.service;


import cn.exrick.xboot.base.XbootBaseService;
import cn.exrick.xboot.modules.base.entity.User;
import cn.exrick.xboot.modules.base.param.ChangeScopeParam;
import cn.exrick.xboot.modules.base.param.QueryUserParam;
import cn.exrick.xboot.modules.base.param.UpdateAdminParam;
import cn.exrick.xboot.modules.base.vo.UserVo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.Cacheable;

import java.util.List;

/**
 * 用户接口
 * @author Exrickx
 */
@CacheConfig(cacheNames = "user")
public interface UserService extends XbootBaseService<User, Long> {

    /**
     * 通过用户名获取用户
     * @param username
     * @return
     */
    @Cacheable(key = "#username")
    User findByUsername(String username);

    /**
     * 通过手机获取用户
     * @param mobile
     * @return
     */
    User findByMobile(String mobile);


    /**
     * 多条件分页获取用户
     * @param user
     * @param searchVo
     * @param pageable
     * @return
     */
    Page<UserVo> findByCondition(Page page, QueryUserParam param);

    /**
     * 通过部门id获取
     * @param departmentId
     * @return
     */
    List<User> findByDepartmentId(Long departmentId);

    /**
     * 更新部门名称
     * @param departmentId
     * @param departmentTitle
     */
    void updateDepartmentTitle(Long departmentId, String departmentTitle);

    User findByOpenId(String openid);

    /**
     * 切换角色
     * @param roles
     * @return
     */
    User changeScope(ChangeScopeParam roles);

    boolean updateAdmin(UpdateAdminParam param);
}
